Skip to content

fix(@ngtools/webpack): show a compilation error on invalid TypeScript version - #23446

Merged
clydin merged 1 commit into
angular:mainfrom
clydin:ngtools/ts-version-error
Jun 28, 2022
Merged

fix(@ngtools/webpack): show a compilation error on invalid TypeScript version#23446
clydin merged 1 commit into
angular:mainfrom
clydin:ngtools/ts-version-error

Conversation

@clydin

@clydin clydin commented Jun 27, 2022

Copy link
Copy Markdown
Member

A TypeScript version mismatch with the Angular compiler will no longer cause an
exception to propagate up through the Webpack system. In Node.js v14, this resulted
in an unhandled promise rejection warning and the build command never completing.
This can also be reproduced in newer versions of Node.js by using the Node.js
option --unhandled-rejections=warn. To correct this issue, the version mismatch
is now treated as a compilation error and added to the list of errors that are
displayed at the end of the build. This also has the benefit of avoiding the stack
trace of the exception from being shown which previously drew attention away from
the actual error message.

New output example:

./src/main.ts - Error: Module build failed (from ./node_modules/@angular-devkit/build-angular/node_modules/@ngtools/webpack/src/ivy/index.js):
Error: Emit

./src/polyfills.ts - Error: Module build failed (from ./node_modules/@angular-devkit/build-angular/node_modules/@ngtools/webpack/src/ivy/index.js):
Error: Emit

Error: Failed to initialize Angular compilation - The Angular Compiler requires TypeScript >=4.6.2 and <4.8.0 but 4.5.5 was found instead.

Closes #23233

Reviewing with hide whitespace enabled is recommended.

@clydin clydin added target: minor This PR is targeted for the next minor release 2022Q3 Fixit labels Jun 27, 2022
Comment thread packages/ngtools/webpack/src/ivy/plugin.ts Outdated
… version

A TypeScript version mismatch with the Angular compiler will no longer cause an
exception to propagate up through the Webpack system. In Node.js v14, this resulted
in an unhandled promise rejection warning and the build command never completing.
This can also be reproduced in newer versions of Node.js by using the Node.js
option `--unhandled-rejections=warn`. To correct this issue, the version mismatch
is now treated as a compilation error and added to the list of errors that are
displayed at the end of the build. This also has the benefit of avoiding the stack
trace of the exception from being shown which previously drew attention away from
the actual error message.
@clydin
clydin force-pushed the ngtools/ts-version-error branch from 5f55ece to 5340db1 Compare June 28, 2022 12:10
@clydin clydin added the action: merge The PR is ready for merge by the caretaker label Jun 28, 2022
@clydin clydin added target: patch This PR is targeted for the next patch release and removed target: minor This PR is targeted for the next minor release labels Jun 28, 2022
@clydin
clydin merged commit 34ecf66 into angular:main Jun 28, 2022
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Jul 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ng build never exits when using an incompatible version of TypeScript

2 participants